package com.itheima.test2;

import java.util.ArrayList;
import java.util.Arrays;

public class Demo2 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("heima001", "张三", 23));
        list.add(new Student("heima002", "李四", 24));
        list.add(new Student("heima003", "张三", 23));
        list.add(new Student("heima001", "张三", 23));
        list.add(new Student("heima001", "张三", 23));
        list.add(new Student("heima002", "李四", 24));
        list.add(new Student("heima001", "张三", 23));
        list.add(new Student("heima002", "李四", 24));
        list.add(new Student("heima002", "李四", 24));
        for (int i = 0; i < list.size(); i++) {
            for (int j = i+1; j < list.size(); j++) {
                if(list.get(i).equals(list.get(j))){
                    list.remove(j);
                    j--;
                }
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).toString());
        }
    }
}
